﻿using System;
using Loki.Utils;
using Luna.UI.Resources;

namespace Luna.UI.Contacts
{
    public class AccountListViewModel : LunaViewModel
    {
        public BindableCollection<DisplayableAccount> Accounts { get; private set; }

        public AccountListViewModel()
        {
            Accounts = CreateCollection<DisplayableAccount>();

            DisplayName = FormNames.ACCOUNT_LIST;

            Load += AccountListViewModel_Load;
        }

        private void AccountListViewModel_Load(object P_Sender, EventArgs e)
        {
            Accounts.Synchronize(ApplicationModel.CRM.Accounts, (data, display) => display.LoadFrom(data), (data, display) => data.ID == display.ID, display => display.Name);
        }
    }
}